//
//  NSPasteboard+logic.h
//  keyboardtest
//
//  Created by  JasonLee on 2022/1/6.
//

#import <Cocoa/Cocoa.h>
#import <objc/runtime.h>
CG_INLINE BOOL
TJJReplaceMethod(Class _class, SEL _originSelector, SEL _newSelector) {
    Method oriMethod = class_getInstanceMethod(_class, _originSelector);
    Method swiMethod = class_getInstanceMethod(_class, _newSelector);
    if (!oriMethod) {
        class_addMethod(_class, _originSelector, method_getImplementation(swiMethod), method_getTypeEncoding(swiMethod));
        method_setImplementation(swiMethod, imp_implementationWithBlock(^(id self,SEL _cmd){}));
    }
    BOOL sucess = class_addMethod(_class, _originSelector, method_getImplementation(swiMethod), method_getTypeEncoding(swiMethod));
    if (sucess) {
        class_replaceMethod(_class,_originSelector ,method_getImplementation(oriMethod) , method_getTypeEncoding(oriMethod));
    }else{
        method_exchangeImplementations(oriMethod, swiMethod);
    }
    return YES;
}

NS_ASSUME_NONNULL_BEGIN

@interface NSPasteboard (logic)

@end

NS_ASSUME_NONNULL_END
